package cn.edu.scau.cmi.suyaoxing.composite.consistent;

import java.util.List;

public class ConsistentLeaf implements ConsistentComponent{
	private int index;
	public ConsistentLeaf(int index) {
		this.index=index;
	}
	public int getIndex() {
		return this.index;
	}
	@Override
	public String doSomething() {
		return "ConsistentComposite doSomething";
	}
	@Override
	public void addChild(ConsistentComponent child) {
		System.out.println("叶子节点无法添加节点");
	}
	@Override
	public void removeChild(int index) {
		System.out.println("叶子节点无法删除节点");
	}
	@Override
	public String toString() {
		return "个体"+this.getIndex();
	}
	public int getSize() {
		return ConsistentComponent.childs.size();
	}
	public ConsistentComponent getChild(int index) {
		return ConsistentComponent.childs.get(index);
	}
	public List<ConsistentComponent> getList() {
		return ConsistentComponent.childs;
	}
}
